package cn.zn.modules.budget.cur.entity.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BudgetInfoSumVO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String sumId;
    private String deptCode;
    private String projectCode;
    private String cateCode;
    private String projectName;
    private String cateName;
    private String deptName;
    private Double totalMoney;
    private String remark;
    private Double freezsMoney;
    private Double useMoney;

    /**
     * 可用金额
     *
     * @return
     */
    public Double getAvailableMoney() {
        BigDecimal bd_total = new BigDecimal(this.totalMoney.toString());
        BigDecimal bd_freezs = new BigDecimal(this.freezsMoney == null ? "0" : this.freezsMoney.toString());
        BigDecimal bd_use = new BigDecimal(this.useMoney == null ? "0" : this.useMoney.toString());
        return bd_total.subtract(bd_freezs).subtract(bd_use).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
    }
}
